import { Application } from "egg";
import { model } from "../../db";

export default function (app: Application) {
  const Device = app.model.define(model.device.table.toUpperCase(), {
    ...model.device.columns,
    ...model.device.virtuals
  });

  // @ts-ignore
  Device.associate = function () {
    app.model.Device.belongsTo(app.model.Application, { foreignKey: "appId", targetKey: "appId", as: "app" });
  };

  return Device;
}
